package com.example.demo;

import com.example.demo.controller.TestController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		// 接收Spring IoC容器
		ApplicationContext context = SpringApplication.run(DemoApplication.class, args);

		// 使用示例获取容器中的对象
		// -- 获取TestController对象
		TestController testBean = context.getBean(TestController.class);
		System.out.println(testBean);

		// -- 获取IoC容器中的所有类名
		for (String x :
				context.getBeanDefinitionNames()) {
			System.out.println(x);
		}
	}

}


